<?php
if (!defined('IS_ADMIN'))
	die('Error 404 : Not found.');

$condition = '';
$url = '?mod=category';

// Popular games
if ($popular == 1) {
	$condition = ' WHERE c_popular = 1';
	$url = '?mod=category&popular=1';
}
// Games is suspended
if ($active == 0) {
	$condition = ' WHERE c_active = 0';
	$url = '?mod=category&active=0';
}

// total number of games
$Sql = 'SELECT c_id
		FROM categories' . $condition;
$total = $db->numRows($Sql);

if ($total > $limit) {
	$panigation = ad_panigation($total, $limit, $page, $url, 4, true);
	$smarty->assign('panigation', $panigation);
}

// list table of games
$Qry = 'SELECT *
		FROM categories' . $condition . '
		ORDER BY c_id DESC
		LIMIT ' . $start . ',' . $limit;
$category = $db->fetchAll($Qry);

// assign
$smarty->assign('category', $category);
// SEO
$smarty->assign('title', 'Category - ' . $lang['home_title']);
// Menu
$smarty->assign('is_menu', 'category');
// display theme using smarty
$smarty->display(str_replace(SKIN, 'admin', SMARTY_TEMP) . 'category.tpl');